<html>
	<head>
		<title>Carnegie FS | Transition Day</title>
		#{include 'html_head.html'/}
		<script type="text/javascript">
			function checknum(obj)
				{ if(/^\d+\.?\d{0,2}$/.test(obj.value)){
				  obj.value = obj.value;
				  }else{
				obj.value = obj.value.substring(0,obj.value.length-1);
				}
			}
		</script>
	</head>
	
	<body>
		<div id="container">
			<!-- Page Header -->
			#{include 'header.html'/}
	
			<!-- Content Area -->
			<div id="content">
				<a href="/employee/"><< Back to main</a>
				<div class="title">Transition Day</div>
				
				<div class="clear"></div>
				
				#{form @EmployeeArea.transitionDay(), name:'transition_form'}
                #{ifErrors}
                #{list items:errors, as:'error' }
                   <p class="error">
                      ${error}
                   </p>
                #{/list}
                #{/ifErrors}
				#{/form}
				<form name="transition" method="post" action="@{EmployeeArea.transitionDay()}" name="transition_form">
					<table>
						<tr>
							<td><div class="tbl_header">Last Closing Date</div></td>
							<td><div class="tbl_row">${formatedLastClosingDate}</div></td>
						</tr>					
						<tr>
							<td><div class="tbl_header">Closing Date</div></td>
							<td><input type="text" class="tbl_row" name="date" placeholder="YYYY-MM-DD" value="${flash.date}"/></td>
						</tr>
						<tr><td colspan="2"><div class="clear"></div></td></tr>
						<tr>
							<td><div class="tbl_header" align="center">Symbol</div></td>
							<td><div class="tbl_header" align="center">Last Closing Price</div></td>
							<td><div class="tbl_header" align="center">New Closing Price</div></td>
						</tr>
							#{list items:funds , as:'fund'}
						<tr>
							<td><div class="tbl_row">${fund.fund.symbol}</div></td>
							<td><div class="tbl_row right_aligned">USD ${fund.price.format('#,###.00')}</div></td>
							<td><input type="text" class="tbl_row right_aligned" name="price" placeholder="in USD" value="${price}" onkeyup="checknum(this);"/></td>
							<td><input type="hidden" name="symbol" value="${fund.fund.symbol}" /></td>
						</tr>
							#{/list}
							
							#{list items:newFunds, as:'newFund'}
						<tr>
							<td><div class="tbl_row">${newFund.symbol}</div></td>
							<td><div class="tbl_row right_aligned">USD 0.00</div></td>
							<td><input type="text" class="tbl_row right_aligned" name="price" placeholder="in USD"/></td>
							<td><input type="hidden" name="symbol" value="${newFund.symbol}" /></td>
						</tr>
							#{/list}
                        <tr><td colspan="2"><div class="clear"></div></td></tr>		
						<tr>
						    <td><div class="tbl_header" align="center">Pending</div></td>
						</tr>
						<tr>
							<td><div class="tbl_header" align="center">Position</div></td>
							<td><div class="tbl_header" align="center">Transaction Type</div></td>
							<td><div class="tbl_header" align="center">Amount</div></td>
						</tr>	
						   #{list items:pendingTransactions, as:'pending_item'}
						<tr>
							<td class="tbl_row"><i><font color="#777">${pending_item.transaction_type}</font></i></td>
							<td class="tbl_row"><i><font color="#777">%{if(pending_item.transaction_type.equalsIgnoreCase("buy") || pending_item.transaction_type.equalsIgnoreCase("sell")){}% ${pending_item.position.fund.symbol} %{}}%</font></i></td>
							<td class="tbl_row right_aligned"><i><font color="#777">USD ${pending_item.amount.format('#,###.00')}%{if(pending_item.transaction_type.equalsIgnoreCase("sell")){}%*%{}}%</font></i></td>
						</tr>
						   #{/list}
												
					</table>
					</br>
					<input type="submit" name="submitData" class="button_black" value="Submit Data" />	
				</form>
				
			</div>
			
			<!-- Page Footer -->
			#{include 'footer.html'/}
			
		</div>
	</body>

</html>